package com.program.cloudmanage.tripteam.controller;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.program.cloudmanage.tripteam.domain.Exit;
import com.program.cloudmanage.tripteam.service.ExitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RefreshScope
@RequestMapping("/Exit")
public class ExitController {
    @NacosInjected
    @Autowired
    private ExitService exitService;

    @GetMapping("/Exit")
    public List<Exit> showExits(){
        return exitService.showExits();
    }

    @GetMapping("/test")
    public String test(){
        return "hello world";
    }

    @PostMapping("/searchExit")
    public Exit searchExit(@RequestBody Exit exit){
        return exitService.searchExit(exit.getExitid());
    }
    @PostMapping("/searchExitByTeamId")
    public Exit searchExitByTeamId(@RequestBody Exit exit){
        return exitService.searchExitByTeamId(exit.getTeamid());
    }

    @PostMapping("/insertExit")
    public String insertExit(@RequestBody Exit exit){
        exitService.insertExit(exit);
        return "OK";
    }

    @PostMapping ("/deleteExit")
    public String deleteExit(@RequestBody Exit exit){
        exitService.deleteExit(exit.getExitid());
        return "OK";
    }

    @PostMapping("/updateExit")
    public String updateExit(@RequestBody Exit exit) {
        exitService.updateExit(exit);
        return "OK";
    }


}